local botaoko = fk.CreateSkill {
  name = "botaoko",
}

Fk:loadTranslationTable{
  ["botaoko"] = "逃寇",
  [":botaoko"] = "每当其他角色使用牌指定你为目标后，你可以：摸两张牌且获得一个&nbsp;“失”&nbsp;标记。每有一个“失”标记，你与其他角色的距离均减少1点。",
  ["$botaoko1"] = "兵法有云，汝不知穷寇莫追乎？！",
  ["$botaoko2"] = "哼，吾等江夏之威，即猛虎毅不敢轻犯！",
}

botaoko:addEffect(fk.TargetConfirmed, {
  anim_type = "drawcard",
  
  can_trigger = function(self, event, target, player, data)
    return target == player and 
           player:hasSkill(botaoko.name) and 
           data.from ~= player and 
           data.card  -- 确保由卡牌指定目标
  end,
  
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, botaoko.name)
  end,
  
  on_use = function(self, event, target, player, data)
    player:drawCards(2, botaoko.name)  -- 摸牌
    player.room:addPlayerMark(player, "@shi", 1)  -- 添加“失”标记
    player.room:notifySkillInvoked(player, botaoko.name)
  end,
})

-- 双向距离修正效果
botaoko:addEffect("distance", {
  correct_func = function(self, from, to)
    local correction = 0
    
    -- 你至其他角色的距离修正：按"失"标记数量减少
    if from:hasSkill(botaoko.name) and from ~= to then
      local shiMarks = from:getMark("@shi")
      correction = correction - shiMarks
    end
    
    -- 其他角色至你的距离修正：按"失"标记数量减少
    if to:hasSkill(botaoko.name) and from ~= to then
      local shiMarks = to:getMark("@shi")
      correction = correction - shiMarks
    end
    
    return correction
  end,
})

return botaoko
